Page({
  data: {
    innerAudioContext: null,
    audioSrc: 'https://files1.peibanw.com/031021-data/upload/20230104/7bec2175fae7e5024074f3334db94091.mp3'
  },

  onShow() {
    const innerAudioContext = wx.createInnerAudioContext({ useWebAudioImplement: false })
    innerAudioContext.loop = true
    innerAudioContext.src = this.data.audioSrc
    this.setData({ innerAudioContext })
  },

  onHide() {
    this.data.innerAudioContext.destroy() // 释放音频资源
    this.setData({ innerAudioContext: null })
  },

  play() {
    this.data.innerAudioContext.play() // 播放
  },

  pause() {
    this.data.innerAudioContext.pause() // 暂停
  },

  stop() {
    this.data.innerAudioContext.stop() // 停止
  }
})